/**
 * Generate code from /{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/domain/{{entities@SQL}}.java.hbs
 */
package cn.ibizlab.core.ad.domain;

import java.util.*;
import cn.ibizlab.util.domain.IEntity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.util.*;
import org.springframework.data.annotation.*;
import cn.ibizlab.util.annotation.*;
import cn.ibizlab.util.enums.*;
import cn.ibizlab.util.domain.EntityMP;
import java.io.Serializable;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.*;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import cn.ibizlab.core.ad.domain.SysOrganizationalRole;
import cn.ibizlab.core.ad.domain.SysPerson;
import cn.ibizlab.core.ad.domain.SysActiveDirectory;

/**
 * 成员实体类[SysMember]
 *
 * @author generator
 */
@Audit
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@JsonIgnoreProperties(value = "handler")
@TableName(value = "SYS_MEMBER", resultMap = "SysMemberResultMap")
@ApiModel(value = "SYS_MEMBER", description = "成员")
public class SysMember extends EntityMP implements Serializable
{

    /**
     * 标识
     */
    @Id
    @TableId(value = "id" , type = IdType.ASSIGN_UUID)
    @DEField(name = "id" , isKeyField = true)
    @JsonProperty("id")
    @JSONField(name = "id")
    @ApiModelProperty(value = "id", notes = "标识")
    private String id;

    /**
     * 创建人
     */
    @TableField(value = "creator" , fill = FieldFill.INSERT)
    @DEField(name = "creator" , preType = DEPredefinedFieldType.CREATEMAN)
    @JsonProperty("creator")
    @JSONField(name = "creator")
    @ApiModelProperty(value = "creator", notes = "创建人")
    private String creator;

    /**
     * 创建时间
     */
    @TableField(value = "create_time" , fill = FieldFill.INSERT)
    @DEField(name = "create_time" , preType = DEPredefinedFieldType.CREATEDATE)
    @JsonProperty("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "create_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "create_time", notes = "创建时间")
    private Date createTime;

    /**
     * 最后更新人
     */
    @TableField(value = "updater")
    @DEField(name = "updater" , preType = DEPredefinedFieldType.UPDATEMAN)
    @JsonProperty("updater")
    @JSONField(name = "updater")
    @ApiModelProperty(value = "updater", notes = "最后更新人")
    private String updater;

    /**
     * 最后更新时间
     */
    @TableField(value = "update_time")
    @DEField(name = "update_time" , preType = DEPredefinedFieldType.UPDATEDATE)
    @JsonProperty("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    @JSONField(name = "update_time" , format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "update_time", notes = "最后更新时间")
    private Date updateTime;

    /**
     * DC
     */
    @TableField(value = "dc")
    @DEField(name = "dc")
    @JsonProperty("dc")
    @JSONField(name = "dc")
    @ApiModelProperty(value = "dc", notes = "DC")
    private String dc;

    /**
     * 用户组标识
     */
    @TableField(value = "organizational_role_id")
    @Audit
    @DEField(name = "organizational_role_id")
    @JsonProperty("organizational_role_id")
    @JSONField(name = "organizational_role_id")
    @ApiModelProperty(value = "organizational_role_id", notes = "用户组标识")
    private String organizationalRoleId;

    /**
     * 用户组名称
     */
    @TableField(value = "organizational_role_name" , exist = false)
    @Audit
    @DEField(name = "organizational_role_name")
    @JsonProperty("organizational_role_name")
    @JSONField(name = "organizational_role_name")
    @ApiModelProperty(value = "organizational_role_name", notes = "用户组名称")
    private String organizationalRoleName;

    /**
     * 部门标识
     */
    @TableField(value = "department_id" , exist = false)
    @DEField(name = "department_id")
    @JsonProperty("department_id")
    @JSONField(name = "department_id")
    @ApiModelProperty(value = "department_id", notes = "部门标识")
    private String departmentId;

    /**
     * 部门编号
     */
    @TableField(value = "department_number" , exist = false)
    @DEField(name = "department_number")
    @JsonProperty("department_number")
    @JSONField(name = "department_number")
    @ApiModelProperty(value = "department_number", notes = "部门编号")
    private String departmentNumber;

    /**
     * 部门名称
     */
    @TableField(value = "department_name" , exist = false)
    @DEField(name = "department_name")
    @JsonProperty("department_name")
    @JSONField(name = "department_name")
    @ApiModelProperty(value = "department_name", notes = "部门名称")
    private String departmentName;

    /**
     * 组织机构标识
     */
    @TableField(value = "organization_id" , exist = false)
    @DEField(name = "organization_id")
    @JsonProperty("organization_id")
    @JSONField(name = "organization_id")
    @ApiModelProperty(value = "organization_id", notes = "组织机构标识")
    private String organizationId;

    /**
     * 机构编号
     */
    @TableField(value = "organization_number" , exist = false)
    @DEField(name = "organization_number")
    @JsonProperty("organization_number")
    @JSONField(name = "organization_number")
    @ApiModelProperty(value = "organization_number", notes = "机构编号")
    private String organizationNumber;

    /**
     * 组织机构名称
     */
    @TableField(value = "organization_name" , exist = false)
    @DEField(name = "organization_name")
    @JsonProperty("organization_name")
    @JSONField(name = "organization_name")
    @ApiModelProperty(value = "organization_name", notes = "组织机构名称")
    private String organizationName;

    /**
     * 人员标识
     */
    @TableField(value = "person_id")
    @Audit
    @DEField(name = "person_id")
    @JsonProperty("person_id")
    @JSONField(name = "person_id")
    @ApiModelProperty(value = "person_id", notes = "人员标识")
    private String personId;

    /**
     * 人员名称
     */
    @TableField(value = "display_name" , exist = false)
    @Audit
    @DEField(name = "display_name")
    @JsonProperty("display_name")
    @JSONField(name = "display_name")
    @ApiModelProperty(value = "display_name", notes = "人员名称")
    private String displayName;

    /**
     * uid
     */
    @TableField(value = "uid" , exist = false)
    @DEField(name = "uid")
    @JsonProperty("uid")
    @JSONField(name = "uid")
    @ApiModelProperty(value = "uid", notes = "uid")
    private String uid;

    /**
     * 排序
     */
    @TableField(value = "sort")
    @DEField(name = "sort")
    @JsonProperty("sort")
    @JSONField(name = "sort")
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "sort", notes = "排序")
    private Long sort;

    /**
     * DN
     */
    @TableField(value = "dn" , exist = false)
    @DEField(name = "dn")
    @JsonProperty("dn")
    @JSONField(name = "dn")
    @ApiModelProperty(value = "dn", notes = "DN")
    private String dn;

    /**
     * ENABLED
     */
    @TableField(value = "enabled" , exist = false)
    @DEField(name = "enabled" , dict = "YesNo")
    @JsonProperty("enabled")
    @JSONField(name = "enabled")
    @ApiModelProperty(value = "enabled", notes = "ENABLED")
    private Integer enabled;

    /**
     * 用户组
     */
    @JsonIgnore
    @JSONField(serialize = false)
    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "organizational_role", notes = "角色")
    private SysOrganizationalRole organizationalRole;

    /**
     * 人员
     */
    @JsonIgnore
    @JSONField(serialize = false)
    @TableField(exist = false)
    @Transient
    @ApiModelProperty(value = "person", notes = "人员")
    private SysPerson person;

    /**
     * 设置 [DC]
     */
    public SysMember setDc(String dc) {
        this.dc = dc;
        this.modify("dc", dc);
        return this;
    }

    /**
     * 设置 [用户组标识]
     */
    public SysMember setOrganizationalRoleId(String organizationalRoleId) {
        this.organizationalRoleId = organizationalRoleId;
        this.modify("organizational_role_id", organizationalRoleId);
        return this;
    }

    /**
     * 设置 [用户组名称]
     */
    public SysMember setOrganizationalRoleName(String organizationalRoleName) {
        this.organizationalRoleName = organizationalRoleName;
        this.modify("organizational_role_name", organizationalRoleName);
        return this;
    }

    /**
     * 设置 [部门标识]
     */
    public SysMember setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
        this.modify("department_id", departmentId);
        return this;
    }

    /**
     * 设置 [部门编号]
     */
    public SysMember setDepartmentNumber(String departmentNumber) {
        this.departmentNumber = departmentNumber;
        this.modify("department_number", departmentNumber);
        return this;
    }

    /**
     * 设置 [部门名称]
     */
    public SysMember setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
        this.modify("department_name", departmentName);
        return this;
    }

    /**
     * 设置 [组织机构标识]
     */
    public SysMember setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
        this.modify("organization_id", organizationId);
        return this;
    }

    /**
     * 设置 [机构编号]
     */
    public SysMember setOrganizationNumber(String organizationNumber) {
        this.organizationNumber = organizationNumber;
        this.modify("organization_number", organizationNumber);
        return this;
    }

    /**
     * 设置 [组织机构名称]
     */
    public SysMember setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
        this.modify("organization_name", organizationName);
        return this;
    }

    /**
     * 设置 [人员标识]
     */
    public SysMember setPersonId(String personId) {
        this.personId = personId;
        this.modify("person_id", personId);
        return this;
    }

    /**
     * 设置 [人员名称]
     */
    public SysMember setDisplayName(String displayName) {
        this.displayName = displayName;
        this.modify("display_name", displayName);
        return this;
    }

    /**
     * 设置 [uid]
     */
    public SysMember setUid(String uid) {
        this.uid = uid;
        this.modify("uid", uid);
        return this;
    }

    /**
     * 设置 [排序]
     */
    public SysMember setSort(Long sort) {
        this.sort = sort;
        this.modify("sort", sort);
        return this;
    }

    /**
     * 设置 [DN]
     */
    public SysMember setDn(String dn) {
        this.dn = dn;
        this.modify("dn", dn);
        return this;
    }

    /**
     * 设置 [ENABLED]
     */
    public SysMember setEnabled(Integer enabled) {
        this.enabled = enabled;
        this.modify("enabled", enabled);
        return this;
    }


    @Override
    public Serializable getDefaultKey(boolean gen) {
        //Assert.notNull(getOrganizationalRoleId(),"未设置用户组标识");
        //Assert.notNull(getPersonId(),"未设置人员标识");
        String key = String.format("%s||%s"
            ,getOrganizationalRoleId(),getPersonId());
        key = DigestUtils.md5DigestAsHex(key.getBytes());    
        return key;
    }

    /**
     * 复制当前对象数据到目标对象(粘贴重置)
     * @param targetEntity 目标数据对象
     * @param includeEmpty  是否包括空值
     * @param <T>
     * @return
     */
    @Override
    public <T> T pasteTo(T targetEntity, boolean includeEmpty) {
        super.pasteTo(targetEntity, includeEmpty);
        if(targetEntity instanceof IEntity) {
            IEntity entity = ((IEntity) targetEntity);
            entity.reset("id");
        }
        return targetEntity;
    }

}